/**
 * losenote.com Inc.
 * Copyright (c) 2013-2013 All Rights Reserved.
 */
package com.losenote.model.ct;

import com.losenote.enums.DataStateEnum;
import com.losenote.enums.UserTypeEnum;
import com.losenote.model.UserInfo;
import com.losenote.orm.UserInfoDO;

/**
 * 用户信息转换
 * 
 * @author danjingyu
 * @version $Id: UserInfoConvertor.java, v 0.1 2013-10-30 下午11:27:39 danjingyu Exp $
 */
public class UserInfoConvertor {

    /**
     * 用户模型转换器
     * 
     * @param userInfoDO
     * @return
     */
    public static UserInfo fromDO(UserInfoDO userInfoDO) {
        if (userInfoDO == null) {
            return null;
        }
        UserInfo info = new UserInfo();
        info.setCreator(userInfoDO.getCreator());
        info.setEmail(userInfoDO.getEmail());
        info.setGmtCreate(userInfoDO.getGmtCreate());
        info.setGmtModified(userInfoDO.getGmtModified());
        info.setId(userInfoDO.getId());
        info.setLastModifier(userInfoDO.getLastModifier());
        info.setMobile(userInfoDO.getMobile());
        info.setName(userInfoDO.getName());
        info.setPassword(userInfoDO.getPassword());
        info.setState(DataStateEnum.getByValue(userInfoDO.getState()));
        info.setUserType(UserTypeEnum.getByValue(userInfoDO.getUserType()));
        return info;
    }
}
